Skip to content

feat: protected labels enforcement with plane-aware authorization - #44664

Merged
Sameeksha Vaity (samvaity) merged 1 commit into
Azure:mainfrom
samvaity:docs/label-approver-pattern
Jul 20, 2026
Merged

Sameeksha Vaity (samvaity) merged 1 commit into
Azure:mainfrom
samvaity:docs/label-approver-pattern

Conversation

@samvaity

@samvaity Sameeksha Vaity (samvaity) commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

Protected Labels Enforcement

Single workflow that enforces label-based authorization. If an unauthorized user applies a protected label, the bot removes it and posts a warning.

How it works

User applies a protected label on a PR
        |
        v
protected-labels.yaml triggers (pull_request_target: labeled)
        |
        v
check-label.js reads .github/protected-labels.yml from base branch
        |
        v
Is the label plane-aware? (management-plane / data-plane keys)
   YES --> detect plane from PR labels:
           Mgmt or resource-manager --> use management-plane approvers
           data-plane              --> use data-plane approvers
           neither                 --> skip (no enforcement)
   NO  --> use the flat approver list
        |
        v
Is user in the authorized list (+ global-approvers)?
   YES --> label stays
   NO  --> label removed + warning comment posted

protected-labels.yml is the single source of truth for label authorization. It supports:

  • global-approvers - GitHub handles that can apply any protected label
  • flat entries - same approvers regardless of plane context
  • plane-aware entries - different approvers for management-plane vs data-plane PRs. Plane is detected explicitly via PR labels (no fallback).

Currently covers namespace approval labels. Other label types (breaking change, versioning) can be added once ownership is clarified with the ARM team.

Consolidation

Deletes .github/namespace-approvers.yml - namespace authorization now lives in protected-labels.yml using plane-aware entries. The namespace-approval workflow (validate-approval.js) focuses on business logic (pending/approved label transitions, status checks) and delegates auth to check-label.js.

Security

  • Uses pull_request_target so config is always read from the base branch (prevents self-authorization)
  • Trusted bots (github-actions[bot], azure-sdk) bypassed
  • namespace-approved-all restricted to management-plane PRs only
  • Case-insensitive GitHub handle matching

@github-actions

github-actions Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Next Steps to Merge

Next steps that must be taken to merge this PR:
  • ❌ The required check named Protected Files has failed. Refer to the check in the PR's 'Checks' tab for details on how to fix it and consult the aka.ms/ci-fix guide


Comment generated by summarize-checks workflow run.

@samvaity
Sameeksha Vaity (samvaity) force-pushed the docs/label-approver-pattern branch 6 times, most recently from db3b461 to 62e9992 Compare July 15, 2026 22:32
@samvaity Sameeksha Vaity (samvaity) changed the title docs: label-based approval pattern for PR workflows feat: protected labels enforcement workflow Jul 15, 2026
@samvaity
Sameeksha Vaity (samvaity) force-pushed the docs/label-approver-pattern branch 8 times, most recently from df43c3b to 4ebca05 Compare July 17, 2026 17:14
@samvaity Sameeksha Vaity (samvaity) changed the title feat: protected labels enforcement workflow feat: protected labels enforcement with plane-aware authorization Jul 17, 2026
@samvaity
Sameeksha Vaity (samvaity) marked this pull request as ready for review July 17, 2026 17:23
Single workflow that prevents unauthorized users from applying protected
labels. Config supports flat approver lists, plane-aware entries
(management-plane/data-plane), and global approvers.

Consolidates namespace-approvers.yml into protected-labels.yml -
approvers.js now derives the ApproversConfig from plane-aware entries.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@samvaity
Sameeksha Vaity (samvaity) merged commit 54f328f into Azure:main Jul 20, 2026
106 of 112 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants